import { createRouter, createWebHistory } from 'vue-router'
import layout from '@/views/layout/LayoutIndex.vue'
import login from '@/views/login/LoginIndex.vue'

const routes = [
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/layout',
    name: 'layout',
    component: layout,
    children: [
      {
        path: '/',
        name: 'home',
        component: () => import('@/views/home/HomeIndex.vue')
      },
      // 产品列表
      {
        path: '/product',
        name: 'product',
        component: () => import('@/views/product/ProductIndex.vue'),
        children: [
          {
            path: 'list',
            name: 'productList',
            component: () => import('@/views/product/list/ListIndex.vue')
          },
          {
            path: 'category',
            name: 'productCategory',
            component: () =>
              import('@/views/product/category/CategoryIndex.vue')
          }
        ]
      },
      // 订单列表
      {
        path: '/order',
        name: 'order',
        component: () => import('@/views/order/OrderIndex.vue'),
        children: [
          {
            path: 'list',
            name: 'orderList',
            component: () => import('@/views/order/list/OrderList.vue')
          },
          {
            path: 'collect',
            name: 'ordercollect',
            component: () => import('@/views/order/collect/OrderCollect.vue')
          }
        ]
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes
})

export default router
